package com.song.JavaThread_ch3_7;

public class TaskMain {
	
	
	
	public static void main(String[] args) {
		MyPhaser phaser = new MyPhaser();
		
		Student students[] = new Student[5];
		for(int i = 0;i<students.length ;i++){
			students[i] = new Student(phaser);
			phaser.register();
		}
		
		Thread threads[] = new Thread[students.length];
		
		for(int i = 0 ; i< students.length ;i++)
		{
			threads[i] = new Thread(students[i],"student"+i);
			threads[i].start();
		}
		for(int i=0 ;i<threads.length;i++)
		{
			try {
				threads[i].join();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		System.out.printf(" Main : the phaser has finish %s \n" , phaser.isTerminated());
	}
}
